package com.yxy.controller;


import com.yxy.service.FileUploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@RestController
@RequestMapping("/file")
public class FileUploadController {

@Autowired
private FileUploadService fileUploadService;

   //文件上传测试
    @PostMapping("/upload")
    @ResponseBody
    public Map<String, Object>  fileUpload(MultipartFile file) {
            Map<String, Object> map = fileUploadService.uploadFile(file);
        return map;
    }

    //文件查看测试
    @GetMapping("/downloadFile")
    @ResponseBody
    public void  downloadFile(HttpServletResponse response, String fileName) {
      fileUploadService.downloadFile(response,fileName);
    }

}
